import { cloudService } from './index'
import type { ISession, IUser } from '@/types/auth'

export const registerApi = (username: string, password: string): Promise<ISession> =>
  cloudService({
    url: '/food-api/user',
    method: 'post',
    params: { username, password }
  })

export const queryUserApi = (id: number): Promise<IUser> =>
  cloudService({
    url: `/food-api/user/${id}`,
    method: 'get'
  })

export const updateUserApi = (id: number, user: IUser): Promise<boolean> =>
  cloudService({
    url: `/food-api/user/${id}`,
    method: 'put',
    data: user
  })
